<template>
  <el-form ref="formRef" :model="option" label-width="120px">
    <el-form-item label="选项内容">
      <el-input v-model="option.optionContent"></el-input>
    </el-form-item>
    <el-form-item label="选项状态">
      <el-switch
          v-model="option.status"
          active-text="启用"
          inactive-text="停用"
          active-color="#13ce66"
          inactive-color="#ff4949"
          active-value="0"
          inactive-value="2"/>
    </el-form-item>
    <el-form-item>
      <el-button @click="add()">添加</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import {addOption} from "@/api/option";
import {ElMessage} from "element-plus";

export default {
  name: "AddOption",
  data(){
    return {
      props:{
        label:'optionContent',
        value:'id'
      },
      options:[],
      option:{
        optionContent:'',
        status:0,
      }
    }
  },
  methods:{
    async add(){
      const rep = await addOption(this.option)
      if (rep.data.code === 200) {
        ElMessage({
          type:'success',
          message:'添加成功'
        })
      }
    }
  }
}
</script>

<style scoped>

</style>